*Descriptive stats table 1.

use data/MMO_tradedata,clear
drop if export == 0
rename iso2 iso2_d
sort iso2_d year
merge iso2_d year using fragrav
tab _merge
tab iso2_d if _merge == 1
drop if _merge !=3
keep firmid year nc8 export qty iso2_d
collapse (sum) export, by(firmid year)
replace export = export/1000000
*
compress
merge m:1 firmid year using brn_eae
table year _merge
drop if _merge ==2
tab _merge
*
replace exp_sales = exp_sales/1000
replace sales = sales/1000
save temp_testexport,replace
*MFG firms
use temp_testexport,replace
keep if manuf==1
collapse (sum) export valueadded employment, by(year _merge)
tsset year
gen laborpty = valueadded/employment
replace export = export/1000
foreach varname of varlist export laborpty {
gen `varname'_g = (100*`varname'/L.`varname')-100
format `varname' %4.1f
format `varname'_g %4.1f
}
foreach varname of varlist valueadded employment {
replace `varname' = `varname'/1000000
gen `varname'_g = (100*`varname'/L.`varname')-100
format `varname' %4.1f
format `varname'_g %4.1f
}
format employment %4.3f
drop _merge
rename export export_mfgsmp
rename export_g export_g_mfgsmp
keep year export* valueadded employment labor*

save temp_testexport1,replace
*TOTAL
use temp_testexport,replace
collapse (sum) export , by(year _merge)
rename _merge merge
reshape wide export, i(year) j(merge)
tsset year
gen exporttot= (export1+export3)/1000
gen exporttot_g = (100*exporttot/L.exporttot)-100

foreach varname of varlist export1 export3 {
replace `varname' = `varname'/1000
replace `varname' = 100*(`varname'/exporttot)
format `varname' %4.1f
}
merge 1:1 year using temp_testexport1
drop _merge export1
format exporttot_g %4.1f
format exporttot %4.1f
replace export_mfgsmp = 100*(export_mfgsmp/exporttot)
format export_mfgsmp %4.1f
order year exporttot  export3 export_mfgsmp exporttot_g export_g_mfgsmp
*
listtex  using $DIRLOG/Replication/tab-descstats.tex, replace rstyle(tabular) 



